home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_gen / freeli10.zip / SPLIT.C < prev    next >
C/C++ Source or Header  |  1996-04-20  |  702b  |  38 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char s[160];
  5.  
  6. main(int argc, char *argv[])
  7. {
  8.     int ctr = 0;
  9.  
  10.     FILE *fp = NULL;
  11.  
  12.     while(!feof(stdin))
  13.     {
  14.         gets(s);
  15.  
  16.         if(s[0] == '~' && s[1] == '~' && s[2] == '~')
  17.         {
  18.             if(fp)
  19.             {
  20.                 printf(" ");
  21.                 if(!(ctr = (ctr + 1) % 6))
  22.                     printf("&\n");
  23.                 fclose(fp);
  24.             }
  25.             printf("+%s", s + 3); 
  26.             strcat(s, ".ASM");
  27.             fp = fopen(s + 3, "wt");
  28.  
  29.         } else {
  30.             if(fp) fprintf(fp, "%s\n", s);
  31.         }
  32.     }
  33.  
  34.     if(argc > 1) printf(" &");
  35.     printf("\n");
  36.     return 0;
  37. }
  38.